import axios from 'axios'
//导入进度条
import nProgress  from 'nprogress'

import "nprogress/nprogress.css"

//对axios进行二次封装
const requests = axios.create({
  baseURL: '/mock',
  timeout: 5000,
})
//请求拦截器
requests.interceptors.request.use((config) => {
  nProgress.start();

  return config
})
//响应拦截器
requests.interceptors.response.use(
  (res) => {
    nProgress.done();
    
    return res.data
  },
  () => {
    return Promise.reject(new Error('false'))
  }
)
export default requests
